Skip to content

Wire up Cloud Run deployment - #7

Merged
amrtgaber merged 1 commit into
mainfrom
phase-a-cloud-run
May 9, 2026
Merged

Wire up Cloud Run deployment#7
amrtgaber merged 1 commit into
mainfrom
phase-a-cloud-run

Conversation

@amrtgaber

Copy link
Copy Markdown
Contributor

Summary

  • Add scripts/deploy.sh for manual Cloud Run deploys (Cloud Build + gcloud run deploy, image tag pinned to the current git short-SHA).
  • Move Alembic out of container startup; migrations are now a separate pre-deploy step against cloud-sql-proxy. Avoids slow Cloud Run cold starts and removes the migration-race risk during concurrent revisions.
  • Add a one-shot migrate service to docker-compose.yml so local dev keeps auto-migrating.
  • Document the new flow in README.md and add .env.production.example as a non-secret reference for prod env vars.

Part of #2 (Phase A — Migrate Treepolitics API to Cloud Run). Domain cutover (api.treepolitics.net) is the remaining piece and is parked pending DNS access; see the latest checkpoint comment on #2 for the resume plan. This PR is independent of that.

Test plan

  • ./scripts/deploy.sh builds + deploys cleanly. New revision treepolitics-api-00002-8sr serving 100% of traffic with image :acae363.
  • Smoke test against the run.app URL with the new revision:
    • /, /health, /docs → 200
    • POST /auth/register → 201
    • POST /auth/jwt/login → 204 + cookies (Domain=.treepolitics.net)
    • GET /auth/me (with cookie) → 200
    • POST /notes + GET /notes (with cookie) → 201 / 200
  • Local sanity check: docker compose up still applies migrations before starting the API (one-shot migrate runs to completion, then api boots).
  • Final smoke at https://api.treepolitics.net once the domain mapping is in place — tracked separately in Phase A — Migrate Treepolitics API to Cloud Run #2.

- scripts/deploy.sh: canonical Cloud Build + gcloud run deploy with
  git-SHA-pinned image tags for clean rollbacks.
- start.sh: drop alembic-on-startup; migrations now run as a separate
  pre-deploy step (avoids slow Cloud Run cold starts and migration races
  across concurrent revisions).
- docker-compose.yml: add one-shot migrate service so docker compose up
  keeps auto-migrating in local dev.
- README: Production Deployment (Cloud Run) section with the deploy
  command, pre-deploy migration procedure, and infra inventory.
- .env.production.example: prod env-var reference (secrets live in
  Secret Manager; non-secrets are baked into scripts/deploy.sh).
@amrtgaber
amrtgaber merged commit fefc9c3 into main May 9, 2026
2 checks passed
@amrtgaber
amrtgaber deleted the phase-a-cloud-run branch May 9, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant